<template>
    <div id="line" :style="chart_style"></div>
</template>

<script>
  import {getHomeData} from '@/api/home.js'
  export default {
     name:"LineChart",
     props:['chart_style'],
     data(){
        return {
            option : {
                title:{
                   text:"近一个月理赔业务数",
                   left:"center",
                   subtext:"单位：笔数"
                },
                xAxis: {
                    type: 'category',
                    data: []
                },
                yAxis: {
                    type: 'value'
                },
                tooltip:{
                    show:true
                },
                series: [{
                    data: [],
                    type: 'line'
                }]
            }
        }
     },
     mounted() {
        var chartDom = document.getElementById('line');
        var myChart = echarts.init(chartDom);
        let that=this;
        getHomeData({type:'line'}).then(function(response){
            if(response.data.code==1){
                that.option.series[0].data=response.data.line_data;
                that.option.xAxis.data=response.data.x_coor;
                myChart.setOption(that.option);
            }
        })
     }
  }
</script>

<style>
</style>
